package com.bckj.fastboot.log.configuration;

import com.aliyun.openservices.ons.api.Producer;
import com.bckj.fastboot.log.BusinessLogAspect;
import com.bckj.fastboot.log.LogProducer;
import com.bckj.fastboot.log.impl.OnsLogProducer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FastLogConfiguration {

    @Bean
    @ConditionalOnBean(Producer.class)
    @ConditionalOnMissingBean(LogProducer.class)
    public LogProducer onsLogProducer(Producer producer) {
        return new OnsLogProducer(producer);
    }

    @Bean
    @ConditionalOnBean(LogProducer.class)
    public BusinessLogAspect businessLogAspect(LogProducer logProducer) {
        return new BusinessLogAspect(logProducer);
    }
}
